﻿using System;
using Avalonia.Controls;
using FluentAvalonia.UI.Controls;
using iOSClub.App.Desktop.ToolPages;
using iOSClub.App.Desktop.ToolPages.Converter;
using iOSClub.App.Desktop.ToolPages.Encode;
using iOSClub.App.Desktop.ToolPages.Generate;
using iOSClub.App.Desktop.ViewModels.ToolPages;

namespace iOSClub.App.Desktop.Pages;

public class ToolNavigationFactory : INavigationPageFactory
{
    public Control GetPage(Type srcType)
    {
        return new TextBlock() { Text = "当前还不支持" };
    }

    public Control GetPageFromObject(object target)
    {
        if (target is Control control) return control;

        if (target is string str)
        {
            return str switch
            {
                "Home" => new ToolHomeView() { DataContext = new HomeViewModel() },
                "Converter" => new ConverterView() { DataContext = new ConverterViewModel() },
                "Translate" => new TranslateView(),
                "BaseConverter" => new BaseConverterView(),
                "RegexConverter" => new RegexConverterView(),
                "Encode" => new EncodeView() { DataContext = new EncodeViewModel() },
                "Base64Image" => new Base64ImageView(),
                "Base64String" => new Base64StringView(),
                "HtmlEncode" => new HtmlEncodeView(),
                "GZipEncode" => new GZipEncodeView(),
                "Generate" => new GenerateView() { DataContext = new GenerateViewModel() },
                "HashGenerate" => new HashGenerateView(),
                _ => new TextBlock() { Text = "当前还不支持" }
            };
        }

        return new TextBlock() { Text = "当前还不支持" };
    }
}